home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / OPENSAVE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  6KB  |  230 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //
  7. // Definition of TOpenSave abstract, TFileOpen, TFileSave common Dialog classes
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_OPENSAVE_H)
  10. #define OWL_OPENSAVE_H
  11.  
  12. #if !defined(OWL_COMMDIAL_H)
  13. # include <owl/commdial.h>
  14. #endif
  15.  
  16. #if defined(BI_NAMESPACE)
  17. namespace OWL {
  18. #endif
  19.  
  20. // Generic definitions/compiler options (eg. alignment) preceeding the 
  21. // definition of classes
  22. #include <services/preclass.h>
  23.  
  24. //
  25. // class TOpenSaveDialog
  26. // ~~~~~ ~~~~~~~~~~~~~~~
  27. class _OWLCLASS TOpenSaveDialog : public TCommonDialog {
  28.   public:
  29.     class _OWLCLASS TData {
  30.       public:
  31.         uint32  Flags;
  32.         uint32  Error;
  33.         char*   FileName;
  34.         char*   Filter;
  35.         char*   CustomFilter;
  36.         int     FilterIndex;
  37.         char*   InitialDir;
  38.         char*   DefExt;
  39.         int     MaxPath;
  40.  
  41.         TData(uint32 flags=0, char* filter=0, char* customFilter=0,
  42.               char* initialDir=0, char* defExt=0,int maxPath=0, 
  43.               int filterIndex = 0);
  44.         TData(const TData& src);
  45.        ~TData();
  46.  
  47.         TData& operator =(const TData& src);
  48.  
  49.         void     SetFilter(const char far* filter = 0);
  50.  
  51.         void     Write(opstream& os);
  52.         void     Read(ipstream& is);
  53.     };
  54.  
  55.     TOpenSaveDialog(TWindow*        parent,
  56.                     TData&          data,
  57.                     TResId          templateId = 0,
  58.                     const char far* title = 0,
  59.                     TModule*        module = 0);
  60.  
  61.     static int GetFileTitleLen(const char far* fileName);
  62.     static int GetFileTitle(const char far* fileName, char far* fileTitle,
  63.                             int bufLen);
  64.  
  65.   protected:
  66.     TOpenSaveDialog(TWindow* parent, TData& data, TModule*   module = 0);
  67.     void    Init(TResId templateId);
  68.     bool    DialogFunction(uint message, TParam1, TParam2);
  69.  
  70.     // Override TWindow & TDialog virtuals
  71.     //
  72.     int     DoExecute() = 0;
  73.  
  74.     // Virtual function called when a share violation occurs in dlg
  75.     //
  76.     virtual int ShareViolation();
  77.  
  78.     // Messages registered by the common dialog DLL
  79.     //
  80.     static uint GetShareViMsgId();
  81.  
  82.     // Default behavior inline for message response functions
  83.     //
  84.     void    CmOk();           //EV_COMMAND(IDOK,
  85.     void    CmLbSelChanged(); //EV_COMMAND(lst1 or lst2
  86.  
  87.     OPENFILENAME& GetOFN();
  88.     void          SetOFN(const OPENFILENAME& _ofn);
  89.  
  90.     TData&  GetData();
  91.     void    SetData(TData& data);
  92.  
  93.   protected_data:
  94.     OPENFILENAME ofn;
  95.     TData&       Data;
  96.  
  97.     static uint ShareViMsgId;
  98.  
  99.   private:
  100.     TOpenSaveDialog(const TOpenSaveDialog&);
  101.     TOpenSaveDialog& operator =(const TOpenSaveDialog&);
  102.  
  103.   DECLARE_RESPONSE_TABLE(TOpenSaveDialog);
  104. };
  105.  
  106. //
  107. // class TFileOpenDialog
  108. // ~~~~~ ~~~~~~~~~~~~~~~
  109. class _OWLCLASS TFileOpenDialog : public TOpenSaveDialog {
  110.   public:
  111.     TFileOpenDialog(TWindow*        parent,
  112.                     TData&          data,
  113.                     TResId          templateId = 0,
  114.                     const char far* title = 0,
  115.                     TModule*        module = 0);
  116.  
  117.     // Override TDialog virtual functions
  118.     //
  119.     int  DoExecute();
  120.  
  121.   private:
  122.     TFileOpenDialog(const TOpenSaveDialog&);
  123.     TFileOpenDialog& operator=(const TOpenSaveDialog&);
  124. };
  125.  
  126. //
  127. // class TFileSaveDialog
  128. // ~~~~~ ~~~~~~~~~~~~~~~
  129. class _OWLCLASS TFileSaveDialog : public TOpenSaveDialog {
  130.   public:
  131.     TFileSaveDialog(TWindow*        parent,
  132.                     TData&          data,
  133.                     TResId          templateId = 0,
  134.                     const char far* title = 0,
  135.                     TModule*        module = 0);
  136.  
  137.     // Override TDialog virtual functions
  138.     //
  139.     int  DoExecute();
  140.  
  141.   private:
  142.     TFileSaveDialog(const TFileSaveDialog&);
  143.     TFileSaveDialog& operator=(const TFileSaveDialog&);
  144. };
  145.  
  146. // Generic definitions/compiler options (eg. alignment) following the 
  147. // definition of classes
  148. #include <services/posclass.h>
  149.  
  150. #if defined(BI_NAMESPACE)
  151. } // namespace OWL
  152. #endif
  153.  
  154. //----------------------------------------------------------------------------
  155. // Inline implementations
  156. //
  157.  
  158. //
  159. // Return the sharing violation message id.
  160. //
  161. inline uint TOpenSaveDialog::GetShareViMsgId()
  162. {
  163.   return ShareViMsgId;
  164. }
  165.  
  166. //
  167. // Return the title length of the dialog.
  168. //
  169. inline int TOpenSaveDialog::GetFileTitleLen(const char far* fileName)
  170. {
  171.   return ::GetFileTitle((LPSTR)fileName, 0, 0);   //Win32 cast
  172. }
  173.  
  174. //
  175. // Return the title of the dialog.
  176. //
  177. inline int TOpenSaveDialog::GetFileTitle(const char far* fileName,
  178.                                          char far* fileTitle,
  179.                                          int fileTitleLen)
  180. {
  181.   return ::GetFileTitle((LPSTR)fileName, fileTitle, (uint16)fileTitleLen);
  182.                         //Win32 casts
  183. }
  184.  
  185. //
  186. inline void TOpenSaveDialog::CmOk()
  187. {
  188.   DefaultProcessing();
  189. }
  190.  
  191. //
  192. inline void TOpenSaveDialog::CmLbSelChanged()
  193. {
  194.   DefaultProcessing();
  195. }
  196.  
  197. //
  198. // Return the OPENFILENAME structure.
  199. //
  200. inline OPENFILENAME& TOpenSaveDialog::GetOFN()
  201. {
  202.   return ofn;
  203. }
  204.  
  205. //
  206. // Set the OPENFILENAME structure for the dialog.
  207. //
  208. inline void TOpenSaveDialog::SetOFN(const OPENFILENAME& _ofn)
  209. {
  210.   ofn = _ofn;
  211. }
  212.  
  213. //
  214. // Retrieve the transfer buffer for the dialog.
  215. //
  216. inline TOpenSaveDialog::TData& TOpenSaveDialog::GetData()
  217. {
  218.   return Data;
  219. }
  220.  
  221. //
  222. // Set the transfer buffer for the dialog.
  223. //
  224. inline void TOpenSaveDialog::SetData(TOpenSaveDialog::TData& data)
  225. {
  226.   Data = data;
  227. }
  228.  
  229. #endif  // OWL_OPENSAVE_H
  230.